using AdminFrame.Application.Contracts.Parameters;
using AdminFrame.Application.Contracts.Parameters.Dtos;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;

namespace AdminFrame.Web.Pages.Parameters
{
    public class CreateModalModel : AbpPageModel
    {

        [BindProperty]
        public ParameterCreateViewModel Parameter { get; set; }

        protected IParameterAppService _parameterAppService;

        public CreateModalModel(IParameterAppService parameterAppService)
        {
            _parameterAppService = parameterAppService;

            Parameter = new();
        }

        public virtual async Task OnGetAsync()
        {
            Parameter = new();

            await Task.CompletedTask;
        }

        public virtual async Task<IActionResult> OnPostAsync()
        {
            await _parameterAppService.CreateAsync(ObjectMapper.Map<ParameterCreateViewModel, CreateUpdateParameterDto>(Parameter));
            return NoContent();
        }
    }

    public class ParameterCreateViewModel : CreateUpdateParameterDto
    {
    }

}